package com.mj.jk.cfg;

import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.autoconfigure.ConfigurationCustomizer;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@MapperScan("com.mj.jk.mapper")
public class MybatisPlusCfg {
    @Bean
    public MybatisPlusInterceptor mybatisPlusInterceptor() {
        MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
        PaginationInnerInterceptor innerInterceptor = new PaginationInnerInterceptor(DbType.MYSQL);
        // 当页数超过最大值时，自动返回第一页
        innerInterceptor.setOverflow(true);
        interceptor.addInnerInterceptor(innerInterceptor);

        return interceptor;
    }

    // 替代 setUseDeprecatedExecutor 的配置方式
    @Bean
    public ConfigurationCustomizer configurationCustomizer() {
        return configuration -> {
            // 根据新版文档调整配置逻辑
            // 例如：启用新的执行器或优化性能
            // 此处假设无需额外配置
        };
    }

}
